package com.ymatou.app.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.api.parameter.SendRegisterValidateCodeBean;
import com.ymatou.app.api.service.SendRegisterValidateCodeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 发送注册验证码 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_SendRegisterValidateCode {
	private static SendRegisterValidateCodeBean srvcbean;
	private static SendRegisterValidateCodeCall srvccall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送注册验证码");
	}

	@Before
	public void caseUp() {
		srvcbean = new SendRegisterValidateCodeBean();
		srvccall = new SendRegisterValidateCodeCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(srvccall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SendRegisterValidateCode_001() {
		Logger.start(true,"发送注册验证码成功");
		try {
			String Phone = TestDataManager.getCommPhoneNum();
			Logger.comment("手机号:" + Phone);
			srvcbean.setPhone(Phone);
			// 发送报文
			srvccall.setData(srvcbean);
			srvccall.callService();
			/*
			 * Logger.debug(srvccall.getEntityString());
			 * Logger.debug(srvccall.getReturnData());
			 */
			Logger.comment("srvccall send:" + srvccall.getEntityString());
			Logger.comment("srvccall response:" + srvccall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, srvccall.getCode(), "验证Code");
			Logger.verifyEquals(ECode.SUCCESSMSG, srvccall.getMsg(), "验证Msg");
			Logger.verifyEquals(ECode.BCODE0, srvccall.getBCode(), "验证BCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}